package com.wym.charging.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 充电记录(ChargingRecord)表实体类
 *
 * @author WangYimin
 * @since 2024-12-08 22:40:50
 */
@Data
@TableName("charging_record")
@Schema(description = "充电记录实体类")
public class ChargingRecord extends Model<ChargingRecord> {
    @TableId
    @Schema(description = "id")
    private Integer id;
    @Schema(description = "用户id")
    private Integer userId;
    @Schema(description = "充电地点")
    private String chargingLocation;
    @Schema(description = "插排编号")
    private Integer powerStripNumber;
    @Schema(description = "充电状态 10：正在充电 20：充电结束")
    private Integer chargingStatus;
    @Schema(description = "充电方式")
    private String chargingMethod;
    @Schema(description = "充电开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime chargingStartTime;
    @Schema(description = "充电结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime chargingEndTime;
    @Schema(description = "扣费方式 10：余额 20：包月")
    private Integer paymentMethod;
    @Schema(description = "消耗余额")
    private BigDecimal remainingBalance;
    @Schema(description = "消耗赠送金额")
    private BigDecimal consumeGiftedAmount;
    @Schema(description = "消耗包月时长")
    private Integer monthlyUsageDuration;
    @Schema(description = "充电总时长")
    private Integer totalChargingTime;
    @Schema(description = "停止原因")
    private String reasonForStopping;
    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    @Schema(description = "假删标识")
    @TableField(fill = FieldFill.INSERT)
    @TableLogic
    private Boolean isDel;

    public String getChargingStatusStr() {
        if (chargingStatus == 10) {
            return "正在充电";
        } else if (chargingStatus == 20) {
            return "充电结束";
        }
        return null;
    }


    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    public Serializable pkVal() {
        return this.id;
    }
}

